#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

static vector<vector<char>> generate_operands() {
    vector<vector<char>> vvc;
    const vector<char> vc {'+', '-', '*', '/'};
    for (int i = 0; i < vc.size(); ++i) {
        for (int j = 0; j < vc.size(); ++j) {
            for (int k = 0; k < vc.size(); ++k) {
                vvc.push_back({vc[i], vc[j], vc[k]});
            }
        }
    }
    return vvc;
}

static vector<vector<int>> generate_operators() {
    vector<vector<int>> vvi;
    constexpr int lim = 10;
    for (int a = 0; a < lim; ++a) {
        for (int b = a + 1; b < lim; ++b) {
            for (int c = b + 1; c < lim; ++c) {
                for (int d = c + 1; d < lim; ++d) {
                    vvi.push_back({a, b, c, d});
                }
            }
        }
    }
    return vvi;
}

static double fuck(double a, double b, char o) {
    constexpr double devide_zero = 1e11;
    if (a == devide_zero)
        return devide_zero;
    if (b == devide_zero) 
        return devide_zero;
    switch (o) {
        case '+': return a + b;
        case '-': return a - b;
        case '*': return a * b;
        case '/': return b != static_cast<double>(0) ? a / b : devide_zero; // avoid division by zero
        default: return 0;
    }
}

int main() {
    constexpr double epsilon = 1e-9;
    auto vector_of_operators = generate_operators();
    auto vector_of_operands = generate_operands();
    int len = 0;
    for (auto& digits : vector_of_operators) {
        vector<bool> ss (1000, false);
        do {
            for (auto& symbols : vector_of_operands) {
                // ab+cd-* : (a + b) * (c - d)
                double s0 = fuck(   fuck(digits[0], digits[1], symbols[0]), 
                                    fuck(digits[2], digits[3], symbols[1]), 
                                    symbols[2]);
                int t0 = static_cast<int>(s0);
                if (s0 > 0 && s0 - t0 < epsilon)
                    ss[t0] = true;

                // ab+c-d* : (a + b - c) * d
                double s1 = fuck(   fuck(fuck(digits[0], digits[1], symbols[0]), digits[2], symbols[1]), 
                                    digits[3], 
                                    symbols[2]);
                int t1 = static_cast<int>(s1);
                if (s1 > 0 && s1 - t1 < epsilon)
                    ss[t1] = true;
            }
        } while (next_permutation(digits.begin(), digits.end()));

        for (int i = 1; i < ss.size(); ++i) {
            if (!ss[i]) {
                if (i > len) {
                    len = i;
                    cout << digits[0] << digits[1] << digits[2] << digits[3] << endl;
                }
                break;
            }
        }
    }
}